Skip to content

Potential fix for code scanning alert no. 13: Uncontrolled command line#19

Merged
Rootless-Ghost merged 1 commit intomainfrom
alert-autofix-13
Apr 26, 2026
Merged

Potential fix for code scanning alert no. 13: Uncontrolled command line#19
Rootless-Ghost merged 1 commit intomainfrom
alert-autofix-13

Conversation

@Rootless-Ghost
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/Rootless-Ghost/AtomicLoop/security/code-scanning/13

To fix this without changing intended functionality, keep accepting hostnames/IPs for WinRM but strictly validate and normalize target_host before it is ever used in cmd_list.

Best approach in this snippet:

  • In core/remote_executor.py, add ipaddress import.
  • Replace regex-only check block at lines around 178–184 with:
    • trim input,
    • attempt ipaddress.ip_address(target_host) for literal IPs (canonical normalization),
    • otherwise validate as RFC-like hostname labels (length + label rules, no leading/trailing hyphen, no empty labels),
    • reject anything else.
  • Use the resulting normalized host string in cmd_list.

This keeps behavior (host/IP accepted, invalid values rejected) while making validation explicit and much harder to bypass than a broad regex.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Rootless-Ghost Rootless-Ghost self-assigned this Apr 26, 2026
@Rootless-Ghost Rootless-Ghost marked this pull request as ready for review April 26, 2026 03:06
@Rootless-Ghost Rootless-Ghost merged commit bd077c2 into main Apr 26, 2026
6 checks passed
@Rootless-Ghost Rootless-Ghost deleted the alert-autofix-13 branch April 26, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant